fix: ensure that @Nullable does not incorrectly affect object schemas#5124
fix: ensure that @Nullable does not incorrectly affect object schemas#5124Mattias-Sehlstedt wants to merge 3 commits into
Conversation
3043ce4 to
23de3a0
Compare
23de3a0 to
8f9aeb7
Compare
02fae4b to
303bce9
Compare
43c78f7 to
76491e1
Compare
|
@Mattias-Sehlstedt thank you for taking your time to work on this issue! I do agree that fixing #5077 under no circumstances should introduce #5115. I have extended your PR to try to cover both of these issues. The commit preserves the nullable by wrapping the property's $ref at resolution time: oneOf for OAS 3.1 and nullable:true + allOf for OAS 3.0. The component schema should remain type:object and not be affected. |
|
Due to my experience with tooling tied to OAS I would suggest that the implementation of There is also the issue that for OAS 3.1., there are many "correct" ways of expressing nullable ref:s. So to better capture this one could preferably have a more semi-formal feat that explained what has been introduced and why (and the basis for the choice of how nullable ref:s are expressed in OAS 3.1). So the new issue would capture why and how, but it could also ensure that So we would keep this PR as a simple "prevent accidental leakage of |
Pull Request
Thank you for contributing to swagger-core!
Please fill out the following information to help us review your PR efficiently.
Description
Changes so that a
@Nullableannotation present on a model does not incorrectly settype: nullfor OAS 3.1 ornullable: truefor OAS 3.0. The nullable is instead dropped entirely. This since the resolving currently does not support an easy way of expressing nullable withrefs correctly as per:OAS3.0
{ "nullable": true, "allOf": [{ "$ref": "#/components/schemas/NestedObject" }] }or
OAS3.1
{ "oneOf": [{ "$ref": "#/components/schemas/NestedObject" }, { "type": "null" }] }Fixes: #5115
Type of Change
Checklist
Screenshots / Additional Context